#include <iostream>
#include <vector>
#include <cstring>
using namespace std;

int aa[200005];
int getNumber(vector<int>& a) {
    memset(aa, 0, sizeof(aa));
    aa[1] = 1;
    for(int i=2;i<200000;i++){
        if(!aa[i]){
            for(int j = i+i;j<=200000;j+=i) aa[j] = 1;
        }
    }
    while(a.size() > 1){
        vector<int> c;
        for(int i=0;i<a.size();i++) if(!aa[i+1]) c.emplace_back(a[i]);
        a = c;
    }
    return a[0];
}

int main(){
    vector<int> a = {1,2,3,4};
    int ans = getNumber(a);
    cout << ans << endl;
    return 0;
}